<head>
    <script src="../build/index.js"></script>
</head>

<body>
    <canvas id="app" width="400" height="800"></canvas>

    <script>
        // var $app = new Easycanvas.Painter(document.getElementById('app'));
        var $app = new Easycanvas.Painter({
            el: document.getElementById('app'),
            width: 300,
            height: 700
        });
        $app.start();

        Easycanvas.ImgLoader('https://raw.githubusercontent.com/c-zhuo/easycanvas/master/demos/G.png', function (img) {
            // create a Sprite
            window.Sprite1 = $app.add({
                name: 'root',
                content: {
                    img: img,
                },
                style: {
                    width: 250, height: 130,
                    cutLeft: 0, cutTop: 0, // source position, default 0
                    left: Easycanvas.Transition.pendulum(111, 222, 1000).loop(),
                    top: $app.height / 10,
                    opacity: 1,
                    rotate: 20,
                    locate: 'center', // default center
                    zIndex: 1, // z-index of this image
                },
                events: {
                    eIndex: 2, // event-index of this image
                    click: function (e) {
                        console.log(e);
                        // "this" means this Sprite, as Sprite1
                        this.style.visible = false;
                        // "true" means stopping bubbling "click" event
                        return true;
                    },
                    // others: mousehold, mousedown, mouseout and touch events
                },
            });
        });
    </script>
</body>

